<ResourceDictionary 
  x:Class="Orbifold.Unfold.Main.OfficeStyleWindow"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
   xmlns:local="clr-namespace:Orbifold.Unfold.Main"
    >
  <!--This tyles the border of the main frame, the edge between the application and the rest of Windows.-->
  <Style TargetType="{x:Type Border}" x:Key = "MainBorder">
    <Setter Property="Background" Value="#B5CBEF" />
    <Setter Property="BorderBrush" Value="#395984" />
    <Setter Property="BorderThickness" Value="1" />
    <Setter Property="CornerRadius" Value="5" />
    <Setter Property="Padding" Value="0" />
  </Style>
  <!--This styles the main Window.-->
  <Style x:Key="OfficeStyle" TargetType="{x:Type Window}">
    <Setter Property="AllowsTransparency" Value="true" />
    <Setter Property="WindowStyle" Value="None" />
    <Setter Property="Background" Value="Transparent" />
    <Setter Property="ResizeMode" Value="CanResizeWithGrip" />   
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type Window}">
          <Grid>
            <Border Width="Auto" Height="Auto" Style="{StaticResource MainBorder}">
              <DockPanel   
                  HorizontalAlignment="Stretch" Background="Transparent" VerticalAlignment="Stretch">
                <local:TitleBar DockPanel.Dock="Top" Title="{TemplateBinding Title}" Icon="{TemplateBinding Icon}" />              
                <ContentPresenter />
              </DockPanel>
            </Border>
            
            <Line MouseDown="OnSizeNorth" Name="lnSizeNorth" Stroke="Transparent"   
              Cursor="SizeNS" X1="10" X2="{TemplateBinding ActualWidth}"
              Y1="1" Y2="1" StrokeThickness="2"  />
                        
            <Line MouseDown="OnSizeSouth" Name="lnSizeSouth" Stroke="Transparent" VerticalAlignment="Bottom" 
                   Cursor="SizeNS" X1="1" X2="{TemplateBinding ActualWidth}" 
                  Y1="{TemplateBinding ActualHeight}" Y2="{TemplateBinding ActualHeight}" StrokeThickness="2" />
            <Line MouseDown="OnSizeWest" Name="lnSizeWest" Stroke="Transparent"
                  Cursor="SizeWE" X1="1" X2="1" Y1="1" Y2="{TemplateBinding ActualHeight}"  StrokeThickness="2" />
            <Line MouseDown="OnSizeEast" Name="lnSizeEast" Stroke="Transparent" HorizontalAlignment="Right" 
                  Cursor="SizeWE" X1="{TemplateBinding ActualWidth}" 
              X2="{TemplateBinding ActualWidth}" Y1="1" Y2="{TemplateBinding ActualHeight}"  StrokeThickness="2" />

            <Rectangle MouseDown="OnSizeNorthWest" Name="rectSizeNorthWest" Cursor="SizeNWSE" Fill="Transparent" Width="5" Height="5" VerticalAlignment="Top" HorizontalAlignment="Left" />
            <Rectangle MouseDown="OnSizeNorthEast" Name="rectSizeNorthEast" Cursor="SizeNESW" Fill="Transparent" Width="5" Height="5" VerticalAlignment="Top" HorizontalAlignment="Right" />
            <Rectangle MouseDown="OnSizeSouthWest" Name="rectSizeSouthWest" Cursor="SizeNESW" Fill="Transparent" Width="5" Height="5" VerticalAlignment="Bottom" HorizontalAlignment="Left" />
            <Rectangle MouseDown="OnSizeSouthEast" Name="rectSizeSouthEast" Cursor="SizeNWSE" Fill="Transparent" Width="5" Height="5" VerticalAlignment="Bottom" HorizontalAlignment="Right" />

          </Grid>          
        </ControlTemplate>
      </Setter.Value>
      
    </Setter>
  </Style>

  <Style TargetType="{x:Type local:ImageButton}">
    <Setter Property="Focusable" Value="false" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type local:ImageButton}">
          <Border Background="{TemplateBinding Background}"
                  BorderBrush="{TemplateBinding BorderBrush}"
                  BorderThickness="{TemplateBinding BorderThickness}">
            <Image Name="PART_img" Source="{Binding Path=ImageNormal, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"  />
          </Border>

          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
              <Setter Property="Source" Value="{Binding Path=ImageOver, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" TargetName="PART_img"/>
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
              <Setter Property="Source" Value="{Binding Path=ImageDown, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" TargetName="PART_img"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style TargetType="{x:Type local:TitleBar}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type local:TitleBar}">
          <Border Name="TitleBar" DockPanel.Dock="Top" 
               Background="{StaticResource TitleBarBackgroundBrush}"  
               BorderThickness="0,0,0,1" 
               BorderBrush="{StaticResource BorderBrush}"
               CornerRadius="5,5,0,0"  >
            <Grid Height="28" >
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="22"/>
                <ColumnDefinition />
                <ColumnDefinition Width="25"/>
                <ColumnDefinition Width="25"/>
                <ColumnDefinition Width="25"/>
              </Grid.ColumnDefinitions>
              <Image Grid.Column="0" Name="Icon" Source="{Binding Path=Icon, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" 
                     HorizontalAlignment="Right" Margin="5,0,0,0" Width="16" Height="16" />
              <TextBlock Grid.Column="1" Name="Caption" Foreground="#3969AD"  HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,0,0"
                         FontFamily="Corbel" FontSize="14" Text="{Binding Path=Title, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />

              <local:ImageButton Grid.Column="2" x:Name="MinButton" 
                  ImageNormal="/images/min.png" 
                  ImageOver="/images/minhot.png" 
                  ImageDown="/images/minpressed.png" Width="25" Height="25" />
              <!--Click="MinButton_MouseLeftButtonDown" />-->

              <local:ImageButton Grid.Column="3" x:Name="MaxButton" 
                   ImageNormal="/images/max_n.png" 
                   ImageOver="/images/maxhot_n.png" 
                   ImageDown="/images/maxpressed_n.png" Width="25" Height="25" />
              <!--Click="MaxButton_MouseLeftButtonDown" />-->

              <local:ImageButton Grid.Column="4" x:Name="CloseButton" 
                    ImageNormal="/images/close_n.png" 
                    ImageOver="/images/closehot_n.png" 
                    ImageDown="/images/closepressed_n.png" Width="25" Height="25" />
              <!--Click="CloseButton_MouseLeftButtonDown" />-->
            </Grid>
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
</ResourceDictionary>